<template>
	<view style="background-color: #f0f2f6;">

		<u-toast ref="uToast"></u-toast><!-- 弹窗 -->
		<!-- 列表 -->
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :sticky="true"
			:down="downOption" :up="upOption" style="z-index: -1;position: absolute;width: 100%;background-color: #f0f2f6;">

			<view class="flow-list" v-if="list.length > 0" style="padding-top: 5px;padding-bottom: 5px;" >
				<view class="flow-list-box">
					<uni-swipe-action ref="swipeAction">
						<uni-swipe-action-item v-for="(item, index) in list" :key="item.id" :threshold="0"
							class="data-item">
							<view class="item" @click="goDetail(item)" :id="'item'+index" ref="mydom"
								style="height: 120px;">
								<view class="item-left">
									<view class="item-left-top">

										<text class="title u-line-1 u-font-30" style="font-weight: bold;">箱号 :<text
												class="titInner">{{item.BoxNo ? item.BoxNo : ''}}</text></text>
									</view>

									<text class="title u-line-1 u-font-26">未扫描 :<text
											class="titInner">{{item.NotScannedCount ? item.NotScannedCount : 0}}</text>
									</text>
									<text class="title u-line-1 u-font-26">已扫描 :<text
											class="titInner">{{item.ScannedCount ? item.ScannedCount : 0}}</text>
									</text>
										<progress activeColor="#55aa7f" stroke-width="10"  :percent="Math.round(item.ScannedCount/(item.ScannedCount+item.NotScannedCount)*100)" show-info style="height:20px; width:100%" />
								
								
								</view>
								<view>
																
								</view>

							</view>
						</uni-swipe-action-item>
					</uni-swipe-action>
				</view>
			</view>
		</mescroll-body>


	</view>
</template>

<script>
	import resources from '@/libs/resources.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {
		GetNoCount

	} from '@/api/q1/business/scan/scan.js'
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				flowStatus: '',
				downOption: {
					use: true,
					auto: true
				},
				upOption: {
					page: {
						num: 0,
						size: 100,
						time: null
					},
					empty: {
						use: true,
						icon: resources.message.nodata,
						tip: "暂无数据",
						fixed: true,
						top: "300rpx",
					},
					textNoMore: '没有更多数据',
				},
				keyword: '',
				list: [],
				options: [{
					text: '查看详情',
					style: {
						backgroundColor: '#c1c1c1'
					}
				}]
			}
		},
		onShow(e) {

			this.upCallback({
				num: 1,
				size: 100
			})

		},
		onUnload() {
			uni.$off('refresh')
		},
		onLoad(e) {

			uni.setNavigationBarTitle({
				title: '做番号:' + e.id
			})
			this.keyword = e.id

		},
		methods: {
			//获取上个页面数据
			getValue(result) {

				if (result == 'success') {

					this.upCallback({
						num: 1,
						size: 100
					})
				}
			},

			upCallback(page) {
				let query = {
					currentPage: page.num,
					pageSize: page.size,
					No: this.keyword
				}
				GetNoCount(query, {
					load: page.num == 1
				}).then(res => {

					this.mescroll.endSuccess(res.data.data.length);
					if (page.num == 1) this.list = [];
					const list = res.data.data.map(o => ({
						...o
					}))
					this.list = this.list.concat(list);
				}).catch(() => {
					this.mescroll.endErr();
				})
			},
			search() {
				// 节流,避免输入过快多次请求
				this.searchTimer && clearTimeout(this.searchTimer)
				this.searchTimer = setTimeout(() => {
					this.list = [];
					this.mescroll.resetUpScroll();
				}, 300)
			},
			goDetail(item) {

				uni.navigateTo({
					url: '/pages/q1/business/scan/scan?BoxNo=' + item.BoxNo + '&No=' + this.keyword

				})


			}

		},



	}
</script>

<style lang="scss" scoped>
	
	@import "@/assets/scss/common.scss";

	page {
		background-color: #f0f2f6;
		height: 100%;
		/* #ifdef MP-ALIPAY */
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		/* #endif */
	}

	

	.flow-list .data-item {
		margin-bottom: 10px;
	}

	.w-100 {
		width: 100rpx;
	}

	.flowLaunch-v {
		width: 100%;

		.flow-list-box {
			width: 95%;

			.item-left-top {
				display: flex;
				width: 100%;

				.common-lable {
					font-size: 24rpx;
					padding: 2rpx 8rpx;
					margin-right: 8rpx;
					border-radius: 8rpx;
					color: #ffffff;
					border: 1px solid #ffffff;
					background-color: #6dcc51;
				}

				.urgent-lable {
					color: #E6A23C;
					border: 1px solid #E6A23C;
					background-color: #fef6e5;
				}

				.important-lable {
					color: #F56C6C;
					border: 1px solid #F56C6C;
					background-color: #fee5e5;
				}

				.title {
					width: unset;
					flex: 1;
					min-width: 0;
				}

			}
		}
	}
</style>